package inits

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
	"video/global"
)

func InitMysql() {
	var err error
	// 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情
	dsn := "root:c258f478e9ad1784478c25a556e45e6a@tcp(124.220.135.42:3306)/video?charset=utf8mb4&parseTime=True&loc=Local"
	global.DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		println(err)
	}

	log.Printf("mysql init success")
}
